package com.baibei.ebec.welfare.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.baibei.ebec.home.R;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.Map;


/**
 * Created by tang on 2018/4/13.
 */

public class IncomeCountAdapater extends RecyclerView.Adapter<IncomeCountAdapater.ViewHolder> {
    private ArrayList<Map<String,String>> datas;
    public IncomeCountAdapater(ArrayList<Map<String,String>> datas){
        this.datas = datas;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_incomecount_welfare, null);
        ViewHolder viewHolder = new ViewHolder(v);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder viewHolder, int i) {
        viewHolder.tvTime.setText(datas.get(i).get("time"));
        viewHolder.tvRegistNum.setText(datas.get(i).get("registTime"));
        viewHolder.tvTradeNum.setText(datas.get(i).get("tradeNum"));
        viewHolder.tvFee.setText(datas.get(i).get("fee"));
        viewHolder.tvBonus.setText(datas.get(i).get("bonus"));
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {

        private final TextView tvTime;
        private final TextView tvRegistNum;
        private final TextView tvTradeNum;
        private final TextView tvFee;
        private final TextView tvBonus;

        public ViewHolder(View itemView) {
            super(itemView);
            tvTime = itemView.findViewById(R.id.tv_time);
            tvRegistNum = itemView.findViewById(R.id.tv_regist_num);
            tvTradeNum = itemView.findViewById(R.id.tv_trade_num);
            tvFee = itemView.findViewById(R.id.tv_fee);
            tvBonus = itemView.findViewById(R.id.tv_bonus);
        }
    }
}
